package com.zwh.se.io;

import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintStream;

/**
 * @author zwh
 * 打印流，输出流的子类，自然拥有着比父类更强的功能
 * 目前可见优点就是多了个自动换行，和当出现null的时候会写入null
 */
public class PrintStreamDemo {
    public static void main(String[] args) throws Exception{
        File file = new File("file/printstream.txt");
        FileOutputStream outputStream = new FileOutputStream(file);
        PrintStream printStream = new PrintStream(outputStream);
        printStream.write("测试写入".getBytes());
        printStream.println("这次写完后就自动换行");
        printStream.print("现在已经是第二行了");
        printStream.close();
    }
}